package com.test;

import javax.swing.event.MenuEvent;
import static java.lang.Math.*;

/**
 * Created by IntelliJ IDEA.
 * User: denny
 * Date: 4/24/13
 * Time: 4:50 PM
 * To change this template use File | Settings | File Templates.
 */
public class NucleusEnergy {
  public static void main(String[] args) {
    // 2.224 Mev for deuteron
    for( int A=2; A<11; A++ ){
      System.out.println(A+" "+bindingEnergyMev(A-1,A));
    }

  }

  static double bindingEnergyMev(int Z, int A){
    int N=A-Z;
    
//    double amu = 931.478; // Mev
//    double mp = 1.007825;
//    double mn = 1.008665;

    // in Mev:
    double a1=15.760;
    double a2=17.810;
    double a3=0.711;
    double a4=23.702;
    double a5=34;

    double e=a1*A -a2*pow(A,2./3) -a3*Z*Z*pow(A,-1./3) -a4*(N-Z)*(N-Z)/A;
    System.out.printf("Parts: %.2f  %.2f  %.2f   %.2f   \n",
        a1*A, -a2*pow(A,2./3), -a3*Z*Z*pow(A,-1./3), -a4*(N-Z)*(N-Z)/A);
    
//    double pairing = a5*pow(A,-3./4);
//    if( Z%2==0 && N%2==0 ) e += pairing;
//    if( Z%2==1 && N%2==1 ) e -= pairing;
    return e;
  }
}
